package ewelinkapi

import (
	"context"
	"encoding/json"

	"gitee.com/libs_2/ewelinkapi/constant"
	"gitee.com/libs_2/ewelinkapi/model"
)

func (c Client) GetHomePage(ctx context.Context, req model.HomeRequest) (model.HomeResponse, error) {
	var res model.HomeResponse
	body, err := json.Marshal(req)
	if err != nil {
		return res, err
	}

	bs, err := c.doPost(ctx, constant.URL_HOME, false, true, false, body)
	if err != nil {
		return res, err
	}

	// fmt.Printf("%v", string(bs))

	err = json.Unmarshal(bs, &res)
	if err != nil {
		return res, err
	}
	return res, nil
}
